import sys
import pandas as pd
import matplotlib.pyplot as plt


def generate_blas_performance_chart(data, png_path, first_name, second_name):
    new_data = {}
    for i in range(0, len(data[0])):
        new_data[data[0][i]] = [v[i] for v in data[1:] if v[0].startswith("Blas")]
        if len(new_data[data[0][i]]) == 0:
            return False
    df = pd.DataFrame(new_data)
    fig, ax = plt.subplots(figsize=(10, 6))
    bars = df.plot(kind='bar', x='Module', y=[first_name, second_name], ax=ax)
    ax.set_title('Compare Blas Performance')
    ax.set_xlabel('Module')
    ax.set_ylabel('Tflops')
    for bar in bars.containers:
        ax.bar_label(bar, label_type='edge',fontsize=6, padding=6)
    plt.xticks(rotation=45, ha='right')
    plt.savefig(png_path)
    return True

